package com.lijin.study.java.merdeal;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.lijin.study.java.util.FileLineProcessor;
import com.lijin.study.java.util.FileUtil;

public class RptMerDeal {

	public static void main(String[] args) throws Exception {
		
//		// 订购商户
//		final List<String> dgMerInfo =  new ArrayList<String>();
//		File dg = new File("D:\\工作目录\\02.日常工作\\生产事件处理\\2013\\互联网业务日报商户信息更新\\DG_MER.txt");
//		FileUtil.readFileByLine(dg, new FileLineProcessor() {
//			@Override
//			public void processLine(String line) {
//				UphisRptMchntInfo mer = new UphisRptMchntInfo();
//				mer.setMchntCd("000000000000000");
//				mer.setMchntNm(line.trim());
//				mer.setSupMchntCd("000000000000000");
//				mer.setSupMchntNm(line.trim());
//				mer.setMchntTp("3");
//				dgMerInfo.add(mer.toInsertSQL());
//			}
//		}, "GBK", 0);
//		FileUtil.writeFileByLine(new File("D:\\DG_MER.sql"), dgMerInfo, "GBK");
		
		// 前台
		final List<String> qtMerInfo =  new ArrayList<String>();
		File qt = new File("D:\\工作目录\\02.日常工作\\生产事件处理\\2013\\互联网业务日报商户信息更新\\QT_MER.txt");
		FileUtil.readFileByLine(qt, new FileLineProcessor() {
			@Override
			public void processLine(String line) {
				UphisRptMchntInfo mer = new UphisRptMchntInfo();
				mer.setMchntCd("000000000000000");
				mer.setMchntNm(line.trim());
				mer.setSupMchntCd("000000000000000");
				mer.setSupMchntNm(line.trim());
				mer.setMchntTp("4");
				qtMerInfo.add(mer.toInsertSQL());
			}
		}, "GBK", 0);
		FileUtil.writeFileByLine(new File("D:\\QT_MER.sql"), qtMerInfo, "GBK");
		
//		// 合并
//		final List<String> mergeMerInfo =  new ArrayList<String>();
//		File merge = new File("D:\\工作目录\\02.日常工作\\生产事件处理\\2013\\互联网业务日报商户信息更新\\MERGE_MER.txt");
//		FileUtil.readFileByLine(merge, new FileLineProcessor() {
//			@Override
//			public void processLine(String line) {
//				UphisRptMchntInfo mer = new UphisRptMchntInfo();
//				String[] merStrArr = line.split("@@");
//				if (merStrArr.length != 3) {
//					System.out.println("error line-->" + line);
//				}
//				mer.setMchntCd(merStrArr[0].trim());
//				mer.setMchntNm(merStrArr[1].trim());
//				mer.setSupMchntCd("000000000000000");
//				mer.setSupMchntNm(merStrArr[2].trim());
//				mer.setMchntTp("1");
//				mergeMerInfo.add(mer.toInsertSQL());
//			}
//		}, "GBK", 0);
//		FileUtil.writeFileByLine(new File("D:\\MERGE_MER.sql"), mergeMerInfo, "GBK");
	}
	
}
